﻿
using System.Collections.Generic;
using System.IO;
using System.Linq;

public enum  FavoriteItemType{
    NotYet,        //未分类
    Education,    //工程教育类
    Japa,        //二次元
}

public class FavoriteItem
{
    public string tag;
    public FavoriteItemType imageSubType;
    public string imagePath;
    //public string
    public string GetName()
    {
        return Path.GetFileNameWithoutExtension(imagePath);
    }
}

public class FavoritesModel

{
    private static FavoritesModel _ins;
    public static FavoritesModel Inst{
        get
        {
            if (_ins == null)
                _ins = new FavoritesModel();
            return _ins;
        }
    }

    private System.Collections.Generic.List<FavoriteItem> _lst = new System.Collections.Generic.List<FavoriteItem>();

    public List<FavoriteItem> GetAll()
    {
        return _lst;
    }

    public List<string> GetAllToString()
    {
        var lst = GetAll();
        var strs = lst.Select(th => th.imagePath).ToArray();
        var rets = new List<string>();
        rets.AddRange(strs);
        return rets;
    }

    public List<FavoriteItem> GetAll(FavoriteItemType type)
    {
        var arr  = _lst.Where(th => th.imageSubType == type).Select(th=>th).ToArray();
        var lst = new List<FavoriteItem>() ;
        lst.AddRange(arr);
        return lst;
    }
    

    public void Add(FavoriteItem modelItem)
    {
        _lst.Add(modelItem);
    }
}
